#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Student
{
public:
    Student(string name, int id);
    ~Student();

    void set_name(string name);
    string get_name() const;

    void set_id(int id);
    int get_id() const;

    friend ostream &operator<<(ostream &out, const Student &stu);
    friend istream &operator>>(istream &in, Student &stu);

private:
    string m_name;
    int m_id;
};

template <typename T>
class Node
{
public:
    Node(T data);
    T m_data;
    Node *next;
};

// 迭代器遍历
template <typename T>
class Link
{
public:
    Link() = default;   //显式地请求编译器生成该类的默认构造函数
    Link(Node<T> *head);
    Link(const Link<T> &other);
    Link(Link<T> &&other);
    ~Link();

    void insert_head(Node<T> &newnode);
    void insert_tail(Node<T> &newnode);
    void insert_mid(Node<T> &newnode, Node<T> &index);

    void delete_node(Node<T> &newnode);

    friend ostream &operator<<(ostream &out, const Link<T> &link);

private:
    Node<T> *m_head;
};

class DoubleLink : public Link<Student>
{
};

template <typename T>
class DLink : public Link<T>
{
};

class Ui
{
public:
    static void ui()
    {

    }
};

class SaveData
{
public:
    virtual void saveData(const Student &stu) = 0;
    virtual void DeleteData(const Student &stu) = 0;
    virtual Student& readData() = 0;
    virtual vector<Student> readAll() = 0;
};

class File : public SaveData
{
public:
    void saveData(const Student &stu);
    void DeleteData(const Student &stu);
    Student& readData();
    vector<Student> readAll();
private:
    string m_filename;
    FILE *m_fp;
};

class Mysql : public SaveData
{
public:
    void saveData(const Student &stu);
    void DeleteData(const Student &stu);
    Student& readData();
    vector<Student> readAll();
};

template <typename T = Link<Student>>
class StudentManager
{
public:
    StudentManager(T &link, SaveData &file);
    void insert_stu(const Student &stu)
    {
        Node<Student> newnode(stu);
        m_link.insert_head(newnode);
        m_file.saveData(stu);
    }
    void delete_stu(const Student &stu);
    void mod_stu(const Student &stu);
    void find_stu(const Student &stu);
    void display_all_stu();

   
    void run()
    {
        Ui::ui();
        // cin
    }

private:
    T &m_link;
    SaveData &m_file;
}; 

class Run
{
public:
    static void Start()
    {
        // Link link;
        //Mysql mysql;
        //SaveData &file = mysql;
        // StudentManager manger(link,file);
        // manegr.run();
    }
};

int main(int argc, char **argv)
{
    Run::Start();
    return 0;
}